{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/article/index')}">公告管理</a></li>
            <li class="layui-this">编辑功公告</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" action="{:url('admin/article/update',['id'=>$article['id']])}" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">选择游戏</label>
                    <div class="layui-input-block">
                        <select name="gid" lay-verify="required" lay-filter="type" lay-search>
                            <option value="0"{if condition="$article['gid'] === '0'"}selected{/if}>全部</option>
                            {foreach name=":get_agent_game()" item="vo"}
                                <option value="{$vo.id}" {if condition="$article['gid'] === $vo['id']"}selected{/if}>{$vo.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">选择渠道</label>
                <div class="layui-input-block">
                <select name="cid" lay-filter="cid" id="cid" lay-search>
                    <option value="0"{if condition="$article['cid'] === 0"}selected{/if}>全部</option>
                {foreach name=":get_channel_list()" item="vo"}
                    <option value="{$vo.id}"{if condition="$article['cid'] == $vo.id"}selected{/if}>{$vo.platform}</option>
                {/foreach}
                </select>
                </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">所属分类</label>
                    <div class="layui-input-block">
                        <select name="category" lay-verify="required" lay-filter="type">
                            {foreach name="category_list" item="vo"}
                                <option value="{$vo.id}"{if condition="$article['category'] === $vo['id']"}selected{/if}>{$vo.name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" value="{$article['title']}" required  lay-verify="required" placeholder="请输入标题" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">开始时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="star_date" value="{$article['star_date']}" class="layui-input" id="star_date">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">结束时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="end_date" value="{$article['end_date']}" class="layui-input" id="end_date">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" value="{$article['sort']}" required  lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否弹窗</label>
                    <div class="layui-input-block">
                        <input type="radio" name="shouye" value="0" title="否" {if condition="$article.shouye==0"} checked="checked"{/if} required  lay-verify="required" class="layui-input">
                        <input type="radio" name="shouye" value="1" title="是" {if condition="$article.shouye==1"} checked="checked"{/if} required  lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <textarea name="content" placeholder="" class="layui-textarea" id="content">{$article['content']}</textarea>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="hidden" name="id" value="{$article.id}">
                        <button class="layui-btn" lay-submit lay-filter="*">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script src="__JS__/ueditor/ueditor.config.js"></script>
<script src="__JS__/ueditor/ueditor.all.min.js"></script>
{/block}
{block name="script"}
<script>
    $(function() {
        var ue = UE.getEditor('content');
    });

    layui.use(['jquery','laydate'],function () {
        var laydate = layui.laydate;
        var $ = layui.$;

        var startDate = layui.laydate.render({
            elem: '#star_date',
            min: '2017-12-28',
            type: 'date',
            //btns: ['confirm'],
            done:function(value,date){
                if( value !== '' ){
                    endDate.config.min.year = date.year;
                    endDate.config.min.month = date.month - 1;
                    var day = date.date;
                    if(date.hours == 23 && date.minutes == 59 && date.seconds == 59){
                        day = day + 1;
                    }else{
                        endDate.config.min.hours = date.hours;
                        endDate.config.min.minutes = date.minutes;
                        endDate.config.min.seconds = date.seconds;
                    }
                    endDate.config.min.date = day;
                    endDate.config.btns = ['clear','confirm'];
                }else{
                    endDate.config.min.year = '';
                    endDate.config.min.month = '';
                    endDate.config.min.date = '';
                    endDate.config.min.hours = '';
                    endDate.config.min.minutes = '';
                    endDate.config.min.seconds = '';
                    endDate.config.btns = ['clear','now','confirm'];
                }
            }
        });


        var endDate = layui.laydate.render({
            elem: '#end_date',
            min: '2017-12-28',
            type: 'date',
            //btns: ['confirm'],
            done:function(value,date){
                if( value !== '' ){
                    startDate.config.max.year = date.year;
                    startDate.config.max.month = date.month - 1;
                    var day = date.date;
                    if(date.hours == 0 && date.minutes == 0 && date.seconds == 0){
                        day = day - 1;
                    }else{
                        startDate.config.max.hours = date.hours;
                        startDate.config.max.minutes = date.minutes;
                        startDate.config.max.seconds = date.seconds;
                    }
                    startDate.config.max.date = day;
                    startDate.config.btns = ['clear','confirm'];
                }else{
                    startDate.config.max.year = '';
                    startDate.config.max.month = '';
                    startDate.config.max.date = '';

                    startDate.config.max.hours = '';
                    startDate.config.max.minutes = '';
                    startDate.config.max.seconds = '';
                    startDate.config.btns = ['clear','now','confirm'];
                }
            }
        });
    });
</script>

{/block}